package jy.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Food entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "food", catalog = "waimai")
public class Food implements java.io.Serializable {

	// Fields

	private Integer id;
	private Ftype ftype;
	private Store store;
	private String name;
	private Float price;
	private String image;
	private String info;
	private Set<Ofood> ofoods = new HashSet<Ofood>(0);

	// Constructors

	/** default constructor */
	public Food() {
	}

	/** minimal constructor */
	public Food(Ftype ftype, Store store, String name, Float price) {
		this.ftype = ftype;
		this.store = store;
		this.name = name;
		this.price = price;
	}

	/** full constructor */
	public Food(Ftype ftype, Store store, String name, Float price,
			String image, String info, Set<Ofood> ofoods) {
		this.ftype = ftype;
		this.store = store;
		this.name = name;
		this.price = price;
		this.image = image;
		this.info = info;
		this.ofoods = ofoods;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "type_id", nullable = false)
	public Ftype getFtype() {
		return this.ftype;
	}

	public void setFtype(Ftype ftype) {
		this.ftype = ftype;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "store_id", nullable = false)
	public Store getStore() {
		return this.store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	@Column(name = "name", nullable = false, length = 40)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "price", nullable = false, precision = 12, scale = 0)
	public Float getPrice() {
		return this.price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	@Column(name = "image", length = 40)
	public String getImage() {
		return this.image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	@Column(name = "info", length = 500)
	public String getInfo() {
		return this.info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "food")
	public Set<Ofood> getOfoods() {
		return this.ofoods;
	}

	public void setOfoods(Set<Ofood> ofoods) {
		this.ofoods = ofoods;
	}

}